#!/bin/bash

if (($EUID!=0));then
    echo "need root!"
    exit 1
fi
version=$(lsb_release -a 2>/dev/null | grep -oP 'Release'|grep -oP '\d.+')
if [[ "$version" == "14.04" ]];then
case "$version" in
    "14.04")
        #ubuntu 14.04
        cp -n /etc/default/grub{,.bak}
        #comment the line GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
        #this will disable the ubuntu purple screen and boot message
        sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT/#&/' /etc/default/grub

        #change GRUB_CMDLINE_LINUX="" to GRUB_CMDLINE_LINUX="text"
        sed -i 's/\(GRUB_CMDLINE_LINUX=\).\+/\1"text"/'/etc/default/grub

        #uncomment #GRUB_TERMINAL=console
        #this makes grub menu into text mode(without background image)
        sed -i 's/GRUB_TERMINAL/#&/' /etc/default/grub

        update-grub
        ;;
    "16.04")
        #ubuntu 16.04
        systemctl set-default multi-user.target
        ;;
esac

#centos 6
/etc/inittab  5->3

#fedora
systemctl set-default multi-user.target

